/**
 * Histogram.java
 * Download free e-books listed in the documentation and build a histogram of each of the word that appeared 
 * in the book. Each of the key-value pairs (a combination of a word entity and its frequency) 
 * should be stored in your FastHashtable. 
 * 
 * To extract and manipulate Strings from a novel,
 * 1)	Split words using the space character
 * 2)	Use only the text part: it includes upper case letters, lower case letters and 
 *      decimal digit numbers. 
 * 3)	Ignore all of other symbols such as mathematical notation, quotation marks, or underscore. 
 *      For example, â€œIâ€™mâ€� should be interpreted as â€œimâ€�
 * 4)	Consider all the words as lowercase. (â€œMyâ€� and â€œmyâ€� are considered the same word  â€œmyâ€�)
 *
 * To satisfy the above requirements, use the provided method getTextOnly(String input) of 
 * the Histogram class. Also, use the method, toLowerCase() of the String class for 
 * the requirement (4).
 *
 *
 * Please note that you should not import java Hashtable or HashMap class here.
 * Make sure that your Histogram is using FastHashtable
 */

import java.io.*;
import java.util.Enumeration;

public class Histogram{
    FastHashtable<String, Integer> ht;
    String inputfile, outputfile;
    
    public Histogram(String _inputfile){
	// Please use the location of file stored in your machine.
	// Do not download books within your software.
	// add your code here
    }

    // Use this method to satisfy the requirements (1) ~ (3) listed above.
    private String getTextOnly(String input){

	char [] chars = input.toCharArray();
		String retStr = "";

	for (int i = 0 ; i< chars.length; i++){
	    if (Character.isLetterOrDigit(chars[i]))retStr = retStr+chars[i];
	}
	return retStr;
    }

    public int getWordCount(){
	// returns total number of entities listed in your FastHashtable
	// add your code here
    	return 0;
    }
    private void buildFastHashtable(){
	// reads text from the location of inputfile
	// build your hashtable 
	// to manipulate words from the book, use getTextOnly() method and 
	// toLowerCase() from java.lang.String class.
	
    }

    // This method prints your histogram. Please do not modify this.
    public void printHistogram(){
	Enumeration<String> mykeys = ht.getKeys();
	int index = 0;
	System.out.println("===============================");
	while(mykeys.hasMoreElements()){
	    String currentKey = mykeys.nextElement();
	    System.out.println(index++ +" "+currentKey+"         "+ ht.retrieve(currentKey));
	}
	System.out.println("===============================");	    
    }

    public int getFrequency(String word){
	// returns the frequency of specified word.
	// add your code here.
    	return 0;
    }

    public String [] getMostFrequentWord(){
	// returns an array of most frequently appeared words. 
	// if there are multiple words appeared same number of times, 
	// all of the words will be stored in the returning array.
	// add your code here.
    	return null;
    }


}